﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using xReplace;
using Pixolut.DataRestoration;
using System.IO;

namespace DataRestorationPlugin
{
    public class DataRestorationCommand : AbstractProcessingCommand
    {
        public DataRestorationCommand(ref Content pipes)
            : base(ref pipes)
        { }

        public override bool ProcessCommand(System.Xml.XmlNodeList param)
        {
            string filename = this.GetNodeValue("filename", param);
            string tolabel = this.GetNodeValue("tolabel", param);
            MemoryStream ms = new MemoryStream();
            TextWriter tmp = new StreamWriter(ms);
            Actions a = new Actions(filename);
            a.Run();
            tmp.Flush();
            TextReader tr = new StreamReader(ms);
            contentPipelines.StoreContent(tolabel, tr.ReadToEnd());
            tmp.Close();
            ms.Close();
            return true;
        }
    }
}


